package com.operate.api.operate.dramas.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.github.pagehelper.PageInfo;
import com.operate.api.base.ApiIndex;
import com.operate.api.base.R;
import com.operate.api.base.RestPage;
import com.operate.api.operate.dramas.domain.vo.*;
import com.operate.api.operate.dramas.service.IDramasService;
import com.operate.api.operate.meal.domain.vo.PackageStateVO;
import com.operate.util.BindingResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


@Api( tags = ApiIndex.DramasController)
@RequestMapping(value = "/api/operate/dramas")
@RestController
@SaCheckLogin
public class DramasController {

    @Autowired
    private IDramasService service;

    @ApiOperation(value = "查询剧目列表")
    @GetMapping(value = "/list")
    public R<RestPage<List<DramasVO>>> list(
            @ApiParam(value = "查询参数") @ModelAttribute DramasSearchVO searchVO) {
        List<DramasVO> list = service.getList(searchVO);
        RestPage restPage = new RestPage(new PageInfo(list), list);
        return new R(restPage);
    }


    @ApiOperation(value = "查询剧目视频列表")
    @GetMapping(value = "/video_list")
    public R<RestPage<List<VideoVO>>> video_list(
            @ApiParam(value = "查询参数") @ModelAttribute VideoSearchVO searchVO) {
        List<VideoVO> list = service.getVideoList(searchVO);
        RestPage restPage = new RestPage( new PageInfo(list),list);
        return new R(restPage);
    }

    @ApiOperation(value = "剧目-上线/下线")
    @PostMapping(value = "/update_lines")
    public R update_ines(@ApiParam(value = "参数")  @RequestBody DramasStateVO vo) {
        service.updateLines(vo);
        return new R();
    }

}